<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>testFor</title>
    <script src="../public/vue.js"></script>
</head>
<body>
<h3>遍历数组</h3>
<ul id="example-1">
    <li v-for="item in fruits" :key="item.message">
        {{ item.message }}
    </li>
</ul>
<ul id="example-2">
    <li v-for="(item, index) in items">
        {{ parentMessage }} - {{ index }} - {{ item.message }}
    </li>
</ul>
<hr/>
<h3>循环里面遍历对象的属性</h3>
<div id="v-for-object" class="demo">
    <div v-for="value in object">
        {{ value }}
    </div>
    <hr/>
    <div  v-for="(value, name) in object">
        {{ name }}: {{ value }}
    </div>
    <hr/>
    <div v-for="(value, name, index) in object">
        {{ index }}--{{ name }}: {{ value }}
    </div>
</div>

</body>
<script type="text/javascript">
    const example1 = new Vue({
        el: '#example-1',
        data: {
            fruits: [
                {message: 'apple'},
                {message: 'banana'},
                {message: 'orange'},
            ]
        }
    });
    const example2 = new Vue({
        el: '#example-2',
        data: {
            parentMessage: 'Parent',
            items: [
                {message: 'Foo'},
                {message: 'Bar'}
            ]
        }
    });
    new Vue({
        el: '#v-for-object',
        data: {
            object: {
                title: 'How to do lists in Vue',
                author: 'Jane Doe',
                publishedAt: '2016-04-10'
            }
        }
    })
</script>
</html>